import 'package:flutter/material.dart';
import 'package:toys_flutter/utils/style_utils.dart';

class MyButton extends StatefulWidget {
  final String title;
  final void Function() onPressed; // 添加 final 关键字

  const MyButton({super.key, required this.title, required this.onPressed});

  @override
  State<MyButton> createState() => _MyButtonState();
}

class _MyButtonState extends State<MyButton> {
  @override
  Widget build(BuildContext context) {
    return TextButton(
      onPressed: widget.onPressed,
      style: TextButton.styleFrom(
        foregroundColor: Colors.white,
        backgroundColor: StyleUtils.primaryColor, // 按钮背景颜色
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
        minimumSize: const Size(0, 0), // 限制按钮的最小尺寸
      ),
      child: Text(widget.title),
    );
  }
}
